CLS
@ECHO OFF
GOTO START
REM If no params are supplied, print appropriate message
:NOPARAMS
ECHO "Supply Scenarios to be profiled"
GOTO END

:START
IF "%1" == "" GOTO NOPARAMS

ECHO Instrumenting Binaries....
REM Instrument all the Fmr DLLs
FOR %%X in (*.dll) do VsInstr.exe %%X >Instrumentation.log 2>InstrumentationErrors.log
ECHO Instrumentation complete. See Instrumentation.log, InstrumentationErrors.log for details...

REM Create the Report Directory
md ProfilingReports 2>>Profile.log

REM For each of the Param supplied, Generate the report
:Loop
IF "%1"=="" GOTO Continue
	ECHO Setting Environment variables for profiling
	CALL VsPerfCLREnv /traceon >Profile.log
	ECHO Starting the Trace
	VsPerfCmd /start:trace /output:ProfilingReports\Report_%1.vsp 2>>Profile.log	
	CALL GenericMethodInvoker.exe %1
	ECHO Stopping Trace
	CALL VSPerfCmd /shutdown
	CALL VSPerfReport ProfilingReports\Report_%1.vsp /PackSymbols 2>>Profile.log
SHIFT
GOTO Loop
:Continue
ECHO Profiling Complete...!
:END